<div class="changepas_page" id="changepas_page" >

    <div class="changepas_title">
        <span>修改密码</span>
        <span class="changepas_landing_title" id="upload" class="js_pasclose" onclick="closechangepas()"><i class="iconfont icon-guanbi"></i></span>
    </div>

    <div id="changepasfrom" class="js_changepasfrom" style="display: inline">
        <form class="form-edit userform">
            <div class="form-edit-profile">
                <label for="" class="form-edit-label"> 旧密码：</label>
                <div class="form-edit-input js_oldpas" id="" >
                    <input type="password" placeholder="请输入旧密码"  class="input-content">
                </div>
            </div>
            <div class="form-edit-profile">
                <label for="" class="form-edit-label"> 新密码：</label>
                <div class="form-edit-input js_newpas">
                    <input type="password" placeholder="请输入新密码"  class="input-content">
                </div>
            </div>
            <div class="form-edit-profile">
                <label for="" class="form-edit-label">确认密码：</label>
                <div class="form-edit-input js_newpass">
                    <input type="password" placeholder="请再次输入新密码" class="input-content">
                </div>
            </div>
            <div class="changepas_buttom">
                <input type="button" onclick="pascheck()" value="修改" class="paschange_okbutton " style="color:#fcfaff">
                <input type="button" onclick="resetpas()" value="重置" class="paschange_resetbutton " style="color:rgba(0,0,0,0.54)">
            </div>
        </form>
        <script type="text/javascript">
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-pink',
                radioClass: 'iradio_square-pink',
            });
        </script>
    </div>

</div>
<div class="commingpage js_changepasconfirm" style="display: none;" >
    <div class="confirm" >
        <div class="landing_title"><i class="iconfont icon-guanbi" onclick="closechangepasconfirm()"></i></div>
        <p class="landing_title_tt js_confirmVlue">确定修改密码吗？</p>
        <input type="button" value="确定" class="isok changepasok" onclick="changeuserpassword()"  >
        <input type="button" value="取消" class="isok isno changepasno" onclick="closechangepasconfirm()">
    </div>
</div>

<script>
    function tip(text){
        var bomb = $(".js_bombword").html(text);
        $(".js_bombpromt").fadeIn().stop(true,true);
        setTimeout(function(e){
            $(".js_bombpromt").fadeOut();
        },1200);
    };
    //关闭修改密码页面
    function closechangepas(){
        $(".js_oldpas :input").val("");
        $(".js_newpas :input").val("");
        $(".js_newpass :input").val("");
        $("#changepassword").css("display","none");
    }
    //关闭修改确认框
    function closechangepasconfirm(){
        $(".js_changepasconfirm").css("display","none");
    }
    //重置文本框
    function resetpas(){
        $(".js_oldpas :input").val("");
        $(".js_newpas :input").val("");
        $(".js_newpass :input").val("");
    }
    //密码文本框验证
    function pascheck(){
        var oldpassword = $(".js_oldpas :input").val();
        var newpassword = $(".js_newpas :input").val();
        var newpasswordcheck = $(".js_newpass :input").val();

        //内容验证
        if (oldpassword == ""){
            $(".js_oldpas input").css("border","1px solid #dc1313c7");
            setTimeout(function(e){
                $(".js_oldpas input").css("border","1px solid #bfcbd9");
            },1200);
            this.tip("旧密码不能为空哦~");
        } else if (newpassword == ""){
            $(".js_newpas input").css("border","1px solid #dc1313c7");
            setTimeout(function(e){
                $(".js_newpas input").css("border","1px solid #bfcbd9");
            },1200);
            this.tip("新密码不能为空哦~");
        } else if (newpasswordcheck == ""){
            $(".js_newpass input").css("border","1px solid #dc1313c7");
            setTimeout(function(e){
                $(".js_newpass input").css("border","1px solid #bfcbd9");
            },1200);
            this.tip("要确认密码哦~");
        } else if (oldpassword == newpassword){
            $(".js_oldpas input").css("border","1px solid #dc1313c7");
            $(".js_newpas input").css("border","1px solid #dc1313c7");
            setTimeout(function(e){
                $(".js_oldpas input").css("border","1px solid #bfcbd9");
                $(".js_newpas input").css("border","1px solid #bfcbd9");
            },1200);
            this.tip("新密码与旧密码不能相同哦~");
        } else if (newpassword != newpasswordcheck){
            $(".js_newpass input").css("border","1px solid #dc1313c7");
            $(".js_newpas input").css("border","1px solid #dc1313c7");
            setTimeout(function(e){
                $(".js_newpass input").css("border","1px solid #bfcbd9");
                $(".js_newpas input").css("border","1px solid #bfcbd9");
            },1200);
            this.tip("两次输入的密码不同呢~");
        }else{
            $(".js_changepasconfirm").css("display","inline");
        }
    }
    //密码修改请求
    function changeuserpassword() {
        var $this = this;
        var oldpassword = $(".js_oldpas :input").val();
        var newpassword = $(".js_newpas :input").val();

        $.ajax({
            url: "music/user/changepassword",
            data: { oldpassword:oldpassword,newpassword:newpassword},
            dataType: "json",
            type: "post",
            success:function (data) {
                var result = data.result;
                if(result == 2){
                    $(".js_changepasconfirm").css("display","none");
                    $(".js_oldpas input").css("border","1px solid #dc1313c7");
                    setTimeout(function(e){
                        $(".js_oldpas input").css("border","1px solid #bfcbd9");
                    },1200);
                    $this.tip("旧密码不正确哦~！");
                }else if(result == 1){
                    //成功则初始化页面并关闭弹窗
                    $(".js_oldpas :input").val("");
                    $(".js_newpas :input").val("");
                    $(".js_newpass :input").val("");
                    $(".js_changepasconfirm").css("display","none");
                    $("#changepassword").css("display","none");
                    $this.tip("密码修改成功~！");
                }else {
                    $(".js_oldpas :input").val("");
                    $(".js_newpas :input").val("");
                    $(".js_newpass :input").val("");
                    $(".js_changepasconfirm").css("display","none");
                    $("#changepassword").css("display","none");
                    $this.tip("密码修改失败了哟~！");
                }
            },
            error:function (data) {
                $this.tip("发生未知错误！");
            }
        });
    }
</script>